package com.budwk.app.sqfwV2.enums.dayingRoad;

import com.budwk.app.sqfw.constants.DictConstants;
import com.budwk.app.sqfwV2.dto.dto.FireSafetyOnDayingRoadPdfDTO;
import com.budwk.app.sqfwV2.dto.dto.centuryCity.SafeCheckTaskParamDataDTO;
import com.budwk.app.sqfwV2.dto.dto.dayingRoad.ProblemParamDTO;
import lombok.Getter;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 大营路问题枚举
 */
@Getter
public enum DayingRoadProblemEnum {

    ONE("1","fireHouseAlarmSystem", "true", "火宅自动报警系统"),
    TWO("2","automaticSprinklerSystem", "true", "自动喷水灭火系统"),
    THREE("3","indoorFireHydrant", "true", "室内消防栓"),
    FORE("4","whetherEquippedFire", "true", "该场所是否配备灭火器"),
    FIVE("5","electricalCircuitSituation", DictConstants.ELECTRICAL_CIRCUIT_QUALIFIED, "电气线路情况"),
    SIX("6","electricBicyclesUse", DictConstants.BICYCLES_NO, "电动自行车使用情况"),
    SEVEN("7","fireHighUsageArea", DictConstants.FLAMES_HIGH_HEAT_NO, "明火、高温加热、取暖设备等的使用地点"),
    EIGHT("8","isCombustiblEexplosive", "false", "是否存放易燃易爆危险品"),
    NINE("9","isBlackAlcoholUsed", "false", "是否使用黑酒精"),
    TEN("10","isPeriodicalAirAndPersonTrain", "true", "是否定期开展消防培训和人员上岗前消防培训"),
    ELEVEN("11","personnelOneThreeSkills", "true", "从业人员是否达到“一懂三会”要求"),
    TWELVE("12","otherHiddenDangers", "false", "其他隐患"),
    THIRTEEN("13","fireOtherIssues", "false", "消防设施的其他问题");

    private final String number;

    private final String code;

    private final String defaultValue;

    private final String desc;

    DayingRoadProblemEnum(String number, String code, String defaultValue, String desc) {
        this.number = number;
        this.code = code;
        this.defaultValue = defaultValue;
        this.desc = desc;
    }

    /**
     * 获取问题的默认值
     * @return
     */
    public static Map<String, String> listDefaultValues() {
        return Arrays.stream(values()).collect(Collectors.toMap(DayingRoadProblemEnum::getCode, DayingRoadProblemEnum::getDefaultValue));
    }

    /**
     * 判断是否和默认值hi一致
     */
    public static boolean isEqualDefaultValue(SafeCheckTaskParamDataDTO p, String code) {
        if (p == null) {
            return false;
        }
        DayingRoadProblemEnum enumByCode = getEnumByCode(code);
        if (enumByCode == null) {
            return false;
        }
        return enumByCode.getDefaultValue().equals(p.getKey());
    }

    /**
     * 获取问题编号
     */
    public static DayingRoadProblemEnum getEnumByCode(String code) {
        Optional<DayingRoadProblemEnum> optional = Arrays.stream(values()).filter(e -> e.getCode().equals(code)).findFirst();
        return optional.orElse(null);
    }

    /**
     * 消防问题枚举
     */
    public static Map<DayingRoadProblemEnum, SafeCheckTaskParamDataDTO> getFireIssusEnum(FireSafetyOnDayingRoadPdfDTO roadPdfDTO) {
        Map<DayingRoadProblemEnum, SafeCheckTaskParamDataDTO> map = new HashMap<>();
        map.put(FORE, roadPdfDTO.getWhetherEquippedFire());
        map.put(FIVE, roadPdfDTO.getElectricalCircuitSituation());
        map.put(SIX, roadPdfDTO.getElectricBicyclesUse());
        map.put(SEVEN, roadPdfDTO.getFireHighUsageArea());
        map.put(EIGHT, roadPdfDTO.getIsCombustiblEexplosive());
        return map;
    }

    public static SafeCheckTaskParamDataDTO initData(DayingRoadProblemEnum fEnum) {
        SafeCheckTaskParamDataDTO s = new SafeCheckTaskParamDataDTO();
        s.setFields(fEnum.getCode()).setKey(fEnum.getDefaultValue()).setRiskDesc(fEnum.getDesc());
        return s;
    }

//    /**
//     * 消防问题
//     */
//    public static SafeCheckTaskParamDataDTO listFirrs() {
//        List<DayingRoadProblemEnum> list = new ArrayList();
//        list.add(DayingRoadProblemEnum.SIX);
//
//
//    }



}
